/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.expath.pkg.saxon.java;

import java.io.File;
import java.lang.reflect.Method;
import net.sf.saxon.Version;

/**
 *
 * @author georgfl
 */
public class EXPathTransform
{
    public static void main(String[] args)
    {
        try {
            String cmd = "java org.expath.pkg.saxon.java.EXPathTransform";
            String repo_name = System.getProperty("org.expath.pkg.saxon.repo");
            File repo = repo_name == null ? null : new File(repo_name);
            int[] ver = Version.getStructuredVersionNumber();
            Class clazz = Class.forName("net.sf.saxon.expath.Transform" + ver[0] + ver[1]);
            Object trans = clazz.newInstance();
            Method m = clazz.getMethod("doTransform", String[].class, String.class, File.class);
            m.invoke(trans, args, cmd, repo);
        }
        catch ( Exception ex ) {
            System.err.println("Error invoking Saxon: " + ex);
            // TODO: Make it an option? (for instance depend on --verbose level...)
            ex.printStackTrace();
        }
    }
}
